<?php

/**
 * order actions.
 *
 * @package    taxichrome
 * @subpackage order
 * @author     Alex <alex.debian@gmail.com>
 * @version    SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
 */
class orderActions extends sfActions
{
  public function executeIndex()
  {
    //$this->taxi_orderList = TaxiOrderPeer::doSelect(new Criteria());
    
    $pager = new sfPropelPager('TaxiOrder', 2);
     
    $pager->setCriteria(new Criteria());
    
    $pager->setPage($this->getRequestParameter('page', 1));
    
    $pager->init();
    
    $this->pager = $pager;
  }

  public function executeCreate()
  {
    $this->form = new TaxiOrderForm();

    $this->setTemplate('edit');
  }

  public function executeEdit($request)
  {
    $this->form = new TaxiOrderForm(TaxiOrderPeer::retrieveByPk($request->getParameter('id')));
  }

  public function executeUpdate($request)
  {
    $this->forward404Unless($request->isMethod('post'));

    $this->form = new TaxiOrderForm(TaxiOrderPeer::retrieveByPk($request->getParameter('id')));

    $this->form->bind($request->getParameter('taxi_order'));
    if ($this->form->isValid())
    {
      $taxi_order = $this->form->save();

      $this->redirect('order/edit?id='.$taxi_order->getId());
    }

    $this->setTemplate('edit');
  }

  public function executeDelete($request)
  {
    $this->forward404Unless($taxi_order = TaxiOrderPeer::retrieveByPk($request->getParameter('id')));

    $taxi_order->delete();

    $this->redirect('order/index');
  }
}
